SYNOPSIS sed [-n] [-g] [-e script] [-f sfilename] [filename ] ...
DESCRIPTION sed reads each filename line by line, edits each line according to a script of commands as specified by the ø-e and ø-f arguments and then copies the edited line to the standard output.
OPTIONS The ø-e option supplies a single edit command from the next argument; if there are several of these they are executed in the order in which they appear. If there is just one ø-e option and no -f's, the ø-e flag may be omitted. An ø-f option causes commands to be taken from the file sfilename; if there are several of these they are executed in the order in which they appear; ø-e and ø-f commands may be mixed. The script or sfilename can be adjacent to the ø-e or ø-f or can be the next argument on the command line. The ø-g option causes sed to act as though every substitute command in the following script has a øg suffix. The ø-n option suppresses the default output.
SCRIPTS A script consists of commands of the following form: [address [,address] ] function [arguments] Normally sed cyclically copies a line of input into a current text buffer, then applies in sequence all commands whose addresses select that line and then copies the buffer to standard output and clears the buffer. The ø-n option suppresses normal output so that only commands which do output (e.g. p) cause any writing to occur. Also, some commands (øn, N) do their own line reads, and some others (ød, D) cause all commands following in the script to be skipped (the øD command also suppresses the clearing of the current text buffer that would normally occur before the next cycle). There is also a second buffer (called the `hold space' that can be copied or appended to or from or swapped with the current text buffer.
ADDRESSES
An address is: a decimal number (which matches that numbered line
where line numbers start at 1 and run cumulatively across files), or a
``$'' (which matches the last line of input), or a
``/regular expression/'' (which matches any line satisfying the
expression. The following rules govern the address matching:
FUNCTIONS
In the following list of functions, the maximum number of addresses
permitted for each function is indicated in parentheses.
An argument denoted text consists of one or more lines, with all
but the last ending with `' to hide the newline. A command with this type
argument must be the last on any command line or ø-e argument. Otherwise
multiple commands may appear on a line separated by ``;" characters. A
command may have a trailing comment indicated by a ``#'' character.
Comment lines begin with a ``#''. Backslashes in text are treated as
described in escape sequences below;
they may be used to protect initial whitespace
against the stripping that is done on every line of
the script.
An argument denoted label, rfile or wfile
(which specify labels or file names) is not processed for
escape sequences. Therefore a ``;" or
a ``#" terminates the label or file name. This simplifies
entering DOS style paths.
Each wfile is created before
processing begins. There can be at
most 10 distinct wfile arguments.
ESCAPE SEQUENCES
The following escape sequences are used to represent unprintable characters
in text, regular expressions and replacement text.
It is ignored in labels and files. If the character following
the `' is not list below the `' causes the character to
be quoted during script input.
The øl command also uses
this convention.
a bell(07)
b backspace(08)
e escape(27)
f formfeed(12)
n newline(10)
r return(13)
t tab(09)
v verticaltab(11)
xhh the ASCII character corresponding to 2 hex digits hh.
the backslash itself.
REGULAR EXPRESSIONS (REs)
Regular expressions can be built up from the following ``single-character"
REs:
ERROR MESSAGES
The following error messages may appear during the compilation
phase of sed processing all cause sed to terminate:
The following warning may be displayed during compilation:
During the actual editing the following fatal errors can occur:
BUGS
I tried to fix every problem I could find, but I believe the follow
bugs still exist in this verstion:
COMPATIBILITY
This version of sed is a modification of the Internet supplied GNU
version. That version was reverse-engineered from BSD 4.1 UNIX sed.
The following changes, modifications and improvements have been made:
This version otherwise appears to be equivalent to the UNIX version on the Sun4 computer. That is I believe anything that sed did on that system, this version of sed will do the same on either a Sun4 or a PC under DOS. If anyone can really explain what sed is really supposed to do as explained in the UNIX documentation I would appreciate the information. The manual page refers to ed for further details which is ambiguous at best and the description I read for either the øD command or the options for the øs command were not understandable by me.
I would appreciate any comments, suggestions and even bug reports. I
sometimes can be reached on INTERNET (the fiscal year is almost over),
but you can always contact me by
mail or phone
Howard Helman helman@elm.sdd.trw.com
Box 340
Manhattan Beach, CA 90266
213.372.5387 or after 11/1/91 310.372.5387